<div class="problemindexholder" problemindex="B">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     B. Minimum number of steps
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     1 second
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     We have a string of letters '
     <span class="tex-font-style-tt">
      a
     </span>
     ' and '
     <span class="tex-font-style-tt">
      b
     </span>
     '. We want to perform some operations on it. On each step we choose one of substrings "
     <span class="tex-font-style-tt">
      ab
     </span>
     " in the string and replace it with the string "
     <span class="tex-font-style-tt">
      bba
     </span>
     ". If we have no "
     <span class="tex-font-style-tt">
      ab
     </span>
     " as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo
     <span class="tex-span">
      10
      <sup class="upper-index">
       9
      </sup>
      + 7
     </span>
     .
    </p>
    <p>
     The string "
     <span class="tex-font-style-tt">
      ab
     </span>
     " appears as a substring if there is a letter '
     <span class="tex-font-style-tt">
      b
     </span>
     ' right after the letter '
     <span class="tex-font-style-tt">
      a
     </span>
     ' somewhere in the string.
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The first line contains the initial string consisting of letters '
     <span class="tex-font-style-tt">
      a
     </span>
     ' and '
     <span class="tex-font-style-tt">
      b
     </span>
     ' only with length from
     <span class="tex-span">
      1
     </span>
     to
     <span class="tex-span">
      10
      <sup class="upper-index">
       6
      </sup>
     </span>
     .
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     Print the minimum number of steps modulo
     <span class="tex-span">
      10
      <sup class="upper-index">
       9
      </sup>
      + 7
     </span>
     .
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>ab<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>1<br/></pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>aab<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>3<br/></pre>
     </div>
    </div>
   </div>
   <div class="note">
    <div class="section-title">
     Note
    </div>
    <p>
     The first example: "
     <span class="tex-font-style-tt">
      ab
     </span>
     "
     <span class="tex-span">
      →
     </span>
     "
     <span class="tex-font-style-tt">
      bba
     </span>
     ".
    </p>
    <p>
     The second example: "
     <span class="tex-font-style-tt">
      aab
     </span>
     "
     <span class="tex-span">
      →
     </span>
     "
     <span class="tex-font-style-tt">
      abba
     </span>
     "
     <span class="tex-span">
      →
     </span>
     "
     <span class="tex-font-style-tt">
      bbaba
     </span>
     "
     <span class="tex-span">
      →
     </span>
     "
     <span class="tex-font-style-tt">
      bbbbaa
     </span>
     ".
    </p>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
